//
//  COMineTableViewCell.swift
//  CocoProject
//
//  Created by Ruthless on 2023/8/24.
//

import UIKit

class COMineTableViewCell: UITableViewCell {
    var model: COMineCellModel? {
        didSet {
            guard let model = model else {return}
            
            logo.image = model.logo
            nameLabel.attributedText = model.name
            hintLabel.text = model.hintText
        }
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        selectionStyle = .none
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func configUI() {
        backgroundColor = .rgba(17, 7, 41, 1)
        contentView.addSubview(logo)
        contentView.addSubview(nameLabel)
        contentView.addSubview(rightImageView)
        contentView.addSubview(hintLabel)
        contentView.addSubview(lineView)
        
        logo.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(20)
        }
        
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(logo.snp.right).offset(25)
            make.centerY.equalToSuperview()
        }
        
        rightImageView.snp.makeConstraints { make in
            make.right.equalToSuperview().inset(20)
            make.centerY.equalToSuperview()
        }
        
        hintLabel.snp.makeConstraints { make in
            make.right.equalTo(rightImageView.snp.left).offset(-13)
            make.centerY.equalToSuperview()
        }
        
        lineView.snp.makeConstraints { make in
            make.right.bottom.equalToSuperview()
            make.height.equalTo(1)
            make.left.equalToSuperview().offset(69)
        }
    }
    private lazy var logo: UIImageView = {
        let imgV = UIImageView()
        return imgV
    }()
    
    private lazy var nameLabel: UILabel = {
        let label = UILabel()
        return label
    }()
    
    private lazy var hintLabel: UILabel = {
        let label = UILabel()
        label.font = .medium(18)
        label.textColor = .white
        return label
    }()
    
    private lazy var rightImageView: UIImageView = {
        let imgV = UIImageView(image: UIImage(named: "Rectangle 350"))
        return imgV
    }()
    
    private lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = .white.withAlphaComponent(0.15)
        return view
    }()
}
